/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ac.za.cput.designpatterns.behavioral.mediator;

/**
 *
 * @author user
 */
public class DollarConvertor {

    Mediator mediator;
    public static final float DOLLAR_UNIT = 1.0f ;
    public static final float EURO_UNIT = 0.7f;
    public static final float KRONA_UNIT = 8.0f ;
    
    public DollarConvertor(Mediator mediator){
        this.mediator = mediator;
        mediator.registerDollarConvertor(this);
    }
    
    public float converEurosToDollars(float euros){
        float dollars = euros * (DOLLAR_UNIT / EURO_UNIT);
        System.out.println("Converting "+ euros + " euros to "+dollars+ " dollar");
        return dollars;
    }
    
     public float converKronorToDollars(float euros){
        float dollars = euros * (DOLLAR_UNIT / EURO_UNIT);
        System.out.println("Converting "+ euros + " euros to "+dollars+ " dollar");
        return dollars;
    }
      public float converCurrencyToDollars(float amount,String unitOfCurrency){
        if("krona".equalsIgnoreCase(unitOfCurrency)){
            return converKronorToDollars(amount);
        }else{
            return converEurosToDollars(amount);
        }
    }
}
